import React from 'react';
import { Link } from 'react-router';
import { Row, Col, Calendar, Form, Input, Icon, Modal, Message } from 'antd';
import ProfitCenter  from './profitCenter';           // 营利总汇图
import ProfitStatistics  from './profitStatistics';   // 盈利统计图
import FinanceCount from './financeCount';            //财务统计图
import JobAlertList from './jobAlert';                //工作提醒列表
import LeftMenu from './../../components/menuBar/leftMenu';
const FormItem = Form.Item;

let workSpace = React.createClass({

  contextTypes: {
    router: React.PropTypes.object
  },

  getInitialState() {
    return {
      visible: false,
      forms: {},
    }
  },
  componentDidMount() {
    this.fetch();
  },

  fetch() {
    let params = this.props.location.state;
    let _me = this;
    Utils.sendAjax({
      url: '/job/statistical/room',
      data: JSON.stringify(params),
      type: 'json',
      callback: function (result) {
        if (result.code == '200') {
          _me.setState({
            forms: result.data
          })
        } else {
          Message.warning(result.message)
        }
      }
    })
  },


  signOut() {
    this.setState({
      visible: true
    })
  },

  handleOk() {
    //let params = {};
    //Utils.sendAjax({
    //  url: '/user/logout',
    //  data: JSON.stringify(params),
    //  callback: (result)=> {
    //    if (result.code == 200) {
    //      this.context.router.push('/login');
    //    }
    //  }
    //})
    this.context.router.push('/login');
    this.handleCancel();
  },

  handleCancel() {
    this.setState({
      visible: false
    })
  },


  onPanelChange(value, mode) {
    /*console.log(value, mode);*/
  },
  render () {
    const forms = this.state.forms;

    return (
      <div className="content-desk">
        <div className="room-list">
          <div className="census-item">
            <div className="bg-item">
              <i className="icon-room1"></i>
            </div>
            <div className="text"><Link to="/landlord/rentManage/rentRooms">
              <Form inline>
                <Col>
                  <FormItem>
                    <label className="form-label">已预订</label>
                    <p>{forms.reserveCount}间</p>
                  </FormItem>
                </Col>
              </Form>
            </Link>

            </div>
          </div>
          <div className="census-item">
            <div className="bg-item bg-item1">
              <i className="icon-room2"></i>
            </div>
            <div className="text"><Link to="/landlord/rentManage/rentRooms">
              <Form inline>
                <Col>
                  <FormItem>
                    <label className="form-label">收租提醒</label>
                    <p>{forms.alertRentCount}间</p>
                  </FormItem>
                </Col>
              </Form>
            </Link>
            </div>
          </div>
          <div className="census-item">
            <div className="bg-item">
              <i className="icon-room3"></i>
            </div>
            <div className="text"><Link to="/landlord/rentManage/rentRooms">
              <Form inline>
                <Col>
                  <FormItem>
                    <label className="form-label">正常出租</label>
                    <p>{forms.payCount}间</p>
                  </FormItem>
                </Col>
              </Form>
            </Link>
            </div>
          </div>
          <div className="census-item">
            <div className="bg-item bg-item1">
              <i className="icon-room4"></i>
            </div>
            <div className="text"><Link to="/landlord/rentManage/rentRooms">
              <Form inline>
                <Col>
                  <FormItem>
                    <label className="form-label">空置房间</label>
                    <p>{forms.burnabyCount}间</p>
                  </FormItem>
                </Col>
              </Form>
            </Link>
            </div>
          </div>
          <div className="census-item">
            <div className="bg-item">
              <i className="icon-room5"></i>
            </div>
            <div className="text"><Link to="/landlord/rentManage/rentRooms">
              <Form inline>
                <Col>
                  <FormItem>
                    <label className="form-label">合约到期</label>
                    <p>{forms.expireCount}间</p>
                  </FormItem>
                </Col>
              </Form>
            </Link>
            </div>
          </div>
          <div className="census-item ">
            <div className="bg-item bg-item1">
              <i className="icon-room4"></i>
            </div>
            <div className="text"><Link to="/landlord/rentManage/rentRooms">
              <Form inline>
                <Col>
                  <FormItem>
                    <label className="form-label">租客欠款</label>
                    <p>{forms.debtCount}间</p>
                  </FormItem>
                </Col>
              </Form>
            </Link>
            </div>
          </div>
        </div>
        <div className="echarts">
          <ProfitCenter />
          <ProfitStatistics />
          <FinanceCount />
        </div>
        <div className="remind">
          <JobAlertList/>
        </div>
      </div>
    );
  }
});

workSpace = Form.create()(workSpace);
export default workSpace

